//
//  NSDictionary+MAAdv.m
//  MateAdv
//
//  Created by 茶 on 2023/9/8.
//

#import "NSDictionary+MAAdv.h"

@implementation NSDictionary (MAAdv)

- (NSString *)encodedJsonString {
    if ([NSJSONSerialization isValidJSONObject:self]) {
        NSError *error;
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self options:0 error:&error];
        NSString *json = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        return json;
    }
    return nil;
}

- (BOOL)containKey:(id)anObject {
    return (![self isKindOfClass:NSNull.class] && [self isKindOfClass:NSDictionary.class] && [self.allKeys containsObject:anObject]);
}

@end
